package com.demo14;

import java.util.*;

public class MapDemo1 {

    public static void main(String[] args) {
        //实例化一个对象
        ArrayList<HashMap<Student,String>> arrayList = new ArrayList<HashMap<Student,String>>();
        //实例化hashMap的的信息操作
        //创建学生对象
        Student s1 = new Student("乔峰",30);
        Student s2 = new Student("段誉",24);
        Student s3 = new Student("黄药师",83);
        Student s4 = new Student("郭靖",25);
        Student s5 = new Student("杨过",20);
        Student s6 = new Student("小龙女",23);
        HashMap<Student, String> tl = new HashMap<Student, String>();
        tl.put(s1,"大辽");
        tl.put(s2,"大理");
        arrayList.add(tl);

        HashMap<Student, String> sd = new HashMap<Student, String>();
        sd.put(s3,"桃花岛");
        sd.put(s4,"襄阳城");
        arrayList.add(sd);

        HashMap<Student, String> xl = new HashMap<>();
        xl.put(s5,"古墓");
        xl.put(s6,"绝情谷底");
        arrayList.add(xl);
        //两层循环数据
        for (HashMap<Student,String> hashMap: arrayList){
            //获取对象信息进行再次循环
            Set<Student> keySet = hashMap.keySet();
            //内层hashMap的循环，使用集合get方法
            for (Student student: keySet){
                System.out.println(student.getName()+","+student.getAge()+"岁，居住在:"+hashMap.get(student));
            }
        }


    }
}
